<?php

require_once(dirname(__FILE__)."/interface.uservalidator.php");

class SimpleFileValidator implements UserValidator {

	private static $VALIDATOR_FILE = "users.data";

	public static function validate($username, $password) {

		$fileData = file_get_contents(self::$VALIDATOR_FILE);
		$users = explode("\n", $fileData);
		for ($i=0; $i<sizeof($users); $i++) {
			$userData = explode("=", $users[$i]);
			if (sizeof($userData) == 2) {
				if ( ($userData[0] == $username) && ($userData[1] == $password) ) {
					return true;
				}
			}
		}

		return false;
	}

}

?>